package com.zoe.app.config;

import com.zoe.app.intercept.UserIntercept;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author zoe.Zhang
 * @date 2022/06/09
 * @description
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    /**
     * Add Spring MVC lifecycle interceptors for pre- and post-processing of controller method invocations and resource
     * handler requests. Interceptors can be registered to apply to all requests or be limited to a subset of URL
     * patterns.
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        UserIntercept userIntercept = new UserIntercept();

        registry.addInterceptor(userIntercept)
                .addPathPatterns("/**");
    }
}
